﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfApplication2.Helpers
{
    public class FormatHelper
    {
        public static string AllWordsToUpper(string cadena)
        {
            if (string.IsNullOrEmpty(cadena))
            {
                return null;
            }
            else
            {
                cadena = cadena.TrimStart();
                string[] a = cadena.Split(' ');

                string join = string.Empty;
                string c;
                foreach (string item in a)
                {
                    c = item.ElementAt(0).ToString().ToUpper();
                    join = join + c + item.Substring(1) + " ";
                }

                join = join.TrimStart();
                return join.TrimEnd();
            }
        }

        public static string FirstWordToUpper(string cadena)
        {
            if (string.IsNullOrEmpty(cadena))
            {
                return null;
            }
            else
            {
                cadena = cadena.TrimStart();
                return cadena.ElementAt(0).ToString().ToUpper() + cadena.Substring(1);
            }
        }

        public static string JustTheDate(string cadena)
        {
            if (string.IsNullOrEmpty(cadena))
            {
                return null;
            }
            else
            {
                return cadena.Split(' ')[0];
            }
        }
    }
}
